﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
</head>
<body style="background-color: white;">
    <div class="data-wrap case">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch">

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l"><span class="WdateFmtErr">*</span>登录账号：</label>
                        <input class="form-control" name="account" type="text" autocomplete="off">
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">权限代码：</label>
                        <input class="form-control" name="authCode" type="text" autocomplete="off">
                    </div>

                    <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                    <button type="button" class="btn btn-default btn-sm active" id="btnCache"><span class="glyphicon glyphicon-search"></span> 缓存</button>
                </form>
            </div>
        </div>
        <div class="paging">
            <div class="data-body data-scroll">
                <div class="data-div-view">
                    <table class="table table-hover table-striped table-bordered">
                        <thead>
                            <tr>
                                <th class="t_l">权限名称 【登录账号： 所属公司：】</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <script type="text/x-dot-template" id="templatePager">
        <div class="data-body data-scroll">
            <div class="data-div-view">
                <table class="table table-hover table-striped table-bordered">
                    <thead>
                        <tr>
                            <th class="t_l">权限名称 【登录账号：{{=it.userName}} 所属公司：{{=it.companyName}}】</th>
                        </tr>
                    </thead>
                    <tbody>
                        {{~it.permissionsCode:item:index}}
                        <tr>
                            <td class="t_l">{{= item }} </td>
                        </tr>
                        {{~}}
                    </tbody>
                </table>
            </div>
        </div>
    </script>
    <script type="text/javascript">
        $(function () {
            $("#btnSearch").click(function () {
                init();
            });
            $("#btnCache").click(function () {
                cache();
            });
        });

        $(document).keyup(function (event) {
            var keycode = event.which;
            if (keycode == 13) {
                init();
            }
        });

        function cache() {

            var data = {};

            var authCode = $("input[name='authCode']").val();
            if (!FlashPay.Util.isNullOrEmptySpance(authCode)) {
                data.authCode = authCode;
            } else {
                FlashPay.UI.Tip_short_warning("权限编码不能为空");
                return;
            }

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/SysAuth/GetCatche",
                data: { key: authCode },
                dataType: "json",
                success: function (response) {
                    if (response != null && response.success) {
                        cover.Remove();
                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning(response.errorMessage);
                    }
                },
                error: function (e) {
                    cover.Remove();

                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试！");
                }
            });
        }

        function init() {

            var data = {};

            var account = $("input[name='account']").val();
            if (!FlashPay.Util.isNullOrEmptySpance(account)) {
                data.account = account;
            } else {
                FlashPay.UI.Tip_short_warning("登录账号不能为空");
                return;
            }

            var authCode = $("input[name='authCode']").val();
            if (!FlashPay.Util.isNullOrEmptySpance(authCode)) {
                data.authCode = authCode;
            }

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/SysAuth/GetPermission",
                data: { Account: account, AuthCode: authCode},
                dataType: "json",
                success: function (response) {
                    if (response != null && response.success) {
                        cover.Remove();
                        var text = doT.template($("#templatePager").text());
                        $(".paging").html("");
                        $(".paging").append(text(response.data));

                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning(response.errorMessage);
                    }
                },
                error: function (e) {
                    cover.Remove();

                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试！");
                }
            });
        }
    </script>
</body>
</html>